/* eslint-disable react/jsx-indent */
import React, { PureComponent } from 'react';
import { PlusOutlined } from '@ant-design/icons';
import { Button } from 'antd';
import router from 'umi/router';

class EditLink extends PureComponent {
  render() {
    const { handleAddLink, data } = this.props;
    return (
      <div>
        {data && data.length
          ? data.map(item => (
              <Button
                size="small"
                key={item.funId}
                style={{ marginRight: 12, marginTop: 16 }}
                onClick={() => {
                  router.push(item.url);
                }}
              >
                {item.functionName}
              </Button>
            ))
          : null}
        <Button
          style={{ marginTop: 16 }}
          size="small"
          type="primary"
          ghost
          icon={<PlusOutlined />}
          onClick={() => handleAddLink(true)}
        >
          添加
        </Button>
      </div>
    );
  }
}

export default EditLink;
